{% extends 'myadmin/base.html' %}
{% block main_body %}
<style>
  .table-box {
        overflow-x: auto;
        margin: 10px 0;
    }
  .dataTable {
        min-width: 1200px;
    }
  .dataTable th, 
  .dataTable td {
        padding: 8px 12px;
        text-align: center;
    }
  .refresh-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding: 5px 0;
    }
  .update-status {
        color: #666;
        font-size: 12px;
    }
  .refresh-btn {
        padding: 3px 8px;
        font-size: 12px;
    }
</style>
<section class="content-header">
    <h1>今日饮食达标用户详情</h1>
    <ol class="breadcrumb">
        <li><a href="{% url 'myadmin_index' %}"><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">今日饮食达标用户详情</li>
    </ol>
</section>
<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">今日饮食达标用户列表</h3>
        </div>
        <div class="box-body">
            
            <div class="table-box">
                <table class="table table-bordered table-striped dataTable">
                    <thead>
                        <tr>
                            <th>用户ID</th>
                            <th>用户名</th>
                            <th>饮食计划名称</th>
                            <th>餐次</th>
                            <th>食物名称</th>
                            <th>食物数量</th>
                            <th>用餐时间</th>
                        </tr>
                    </thead>
                    <tbody id="recordsTableBody">
                        {% for record in records %}
                            {% for plan in record.user.diet_plans.all %}
                                {% for detail in plan.details.all %}
                                    <tr>
                                        <td>{{ record.user.user_id }}</td>
                                        <td>{{ record.user.username }}</td>
                                        <td>{{ plan.plan_name }}</td>
                                        <td>{{ detail.meal_type }}</td>
                                        <td>{{ detail.food.food_name }}</td>
                                        <td>{{ detail.quantity }}g</td>
                                        <td>{{ detail.meal_time|date:"H:i" }}</td>
                                    </tr>
                                {% endfor %}
                            {% endfor %}
                        {% empty %}
                            <tr><td colspan="7">暂无今日饮食达标用户记录</td></tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>


{% endblock %}